package service

import (
	"gitee.com/crack007/goose"
	"gitee.com/crack007/goose/core/server"
	"gitee.com/crack007/udp-penetrate/src/common/dto"
)

type userService struct {
	userMap    map[uint32]*dto.UserDto
	sessionMap map[uint32]*server.Session
}

func (s *userService) CheckIn(userDto *dto.UserDto, session *server.Session) {
	goose.GetLogger().Debug("User checkIn uid=%d host=%s port=%d", userDto.Uid, session.RemoteIp, session.RemotePort)
	s.userMap[userDto.Uid] = userDto
	s.sessionMap[userDto.Uid] = session
}

func (s *userService) GetSessionByUid(uid uint32) *server.Session {
	if v, ok := s.sessionMap[uid]; ok {
		return v
	}
	return nil
}
